package cn.aiyuan.utils;

import org.springframework.web.multipart.MultipartFile;

import java.util.UUID;

public class FileUtil {



	/* connect path (include filename) */
	public static String concatAllPath(String... pathList) {
		StringBuilder path = new StringBuilder();
		for (int i = 0; i < pathList.length; i++) {
			if (i != 0) {
				path.append("/").append(pathList[i]);
			} else {
				path.append(pathList[i]);
			}
		}
		return path.toString();
	}



	// 获取文件后缀名
	public static String createUuIdName(MultipartFile file) {
		String saveFileName = file.getOriginalFilename();
		// 获取后缀名
		String[] strArray = saveFileName.split("\\.");
		int suffixIndex = strArray.length - 1;
		String exe = strArray[suffixIndex];
		return UUID.randomUUID().toString().replaceAll("-", "") + "." + exe;
	}


}
